//**************************************************************************
// Copyright 2008 Peter Project (http://www.codeplex.com/peter)
//
// License : GNU General Public License (GPL)
// For full text of the license please goto:
// http://www.gnu.org/licenses/gpl-2.0.html
//
// This code is provided on an AS IS basis, with no WARRANTIES,
// CONDITIONS or GUARANTEES of any kind.
//
//		File: cDirectorySorter.cs
//
//**************************************************************************

using System.Collections;
using System.IO;

namespace Peter
{
    /// <summary>Provides IComparer by comparing directory names</summary>
    /// <remarks>It is assumed that each object passed into Compare is an instance of
    /// <see cref="T:System.IO.DirectoryInfo">DirectoryInfo</see></remarks>
    public class cDirectorySorter : IComparer
    {
        public int Compare(object x, object y)
        {
            DirectoryInfo dir1 = (DirectoryInfo)x;
            DirectoryInfo dir2 = (DirectoryInfo)y;
            return dir1.Name.CompareTo(dir2.Name);
        }
    }

    /// <summary>Provides IComparer by comparing file names</summary>
    /// <remarks>It is assumed that each object passed into Compare is an instance of
    /// <see cref="T:System.IO.FileInfo">FileInfo</see></remarks>
    public class cFileSorter : IComparer
    {
        public int Compare(object x, object y)
        {
            FileInfo file1 = (FileInfo)x;
            FileInfo file2 = (FileInfo)y;
            return file1.Name.CompareTo(file2.Name);
        }
    }
}
